<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>公告 - 博客管理系统</title>

  <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/back/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/back/css/style.css">
  <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/back/css/font-awesome.min.css">
  <link rel="apple-touch-icon-precomposed" href="<%=request.getContextPath()%>/back/images/icon/icon.png">
  <link rel="shortcut icon" href="<%=request.getContextPath()%>/back/images/icon/favicon.ico">
  <script src="<%=request.getContextPath()%>/back/js/jquery-2.1.4.min.js"></script>
  <!--[if gte IE 9]>
  <script src="<%=request.getContextPath()%>/back/js/jquery-1.11.1.min.js" type="text/javascript"></script>
  <script src="<%=request.getContextPath()%>/back/js/html5shiv.min.js" type="text/javascript"></script>
  <script src="<%=request.getContextPath()%>/back/js/respond.min.js" type="text/javascript"></script>
  <script src="<%=request.getContextPath()%>/back/js/selectivizr-min.js" type="text/javascript"></script>
<![endif]-->
<!--[if lt IE 9]>
  <script>window.location.href='upgrade-browser.html';</script>
<![endif]-->
</head>

<body class="user-select">
<section class="container-fluid">
  <header>
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">切换导航</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
          <a class="navbar-brand" href="/">YlsatCMS</a> </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="">消息 <span class="badge">1</span></a></li>
            <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">admin <span class="caret"></span></a>
              <ul class="dropdown-menu dropdown-menu-left">
                <li><a title="查看或修改个人信息" data-toggle="modal" data-target="#seeUserInfo">个人信息</a></li>
                <li><a title="查看您的登录记录" data-toggle="modal" data-target="#seeUserLoginlog">登录记录</a></li>
              </ul>
            </li>
            <li><a href="/Index/outLogin" onClick="if(!confirm('是否确认退出？'))return false;">退出登录</a></li>
            <li><a data-toggle="modal" data-target="#WeChat">帮助</a></li>
          </ul>
          <form action="" method="post" class="navbar-form navbar-right" role="search">
            <div class="input-group">
              <input type="text" class="form-control" autocomplete="off" placeholder="键入关键字搜索" maxlength="15">
              <span class="input-group-btn">
              <button class="btn btn-default" type="submit">搜索</button>
              </span> </div>
          </form>
        </div>
      </div>
    </nav>
  </header>
  <div class="row">
    <jsp:include page="aside.jsp"></jsp:include>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
      <form action="Article/checkAll" method="post" >
        <h1 class="page-header">操作</h1>
        <ol class="breadcrumb">
          <c:if test="${noticeNumber>=0 && noticeNumber<5}"><li><a href="<%=request.getContextPath()%>/back/addNotice">增加公告</a></li></c:if>
          <c:if test="${noticeNumber==5}"><li><a href="<%=request.getContextPath()%>/back/addNotice" title="公告只能五条" onclick="return false;">增加公告</a></li></c:if>
        </ol>
        <h1 class="page-header">管理 <span class="badge">3</span></h1>
        <div class="table-responsive">
          <table class="table table-striped table-hover">
            <thead>
              <tr>
                <th><span class="glyphicon glyphicon-th-large"></span> <span class="visible-lg">选择</span></th>
                <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">标题</span></th>
                <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">日期</span></th>
                <th><span class="glyphicon glyphicon-pencil"></span> <span class="visible-lg">操作</span></th>
              </tr>
            </thead>
            <tbody>
              <c:forEach items="${noticeList}" var="n">
                <tr>
                  <td><input type="checkbox" class="input-control" name="checkbox[]" value="" /></td>
                  <td class="article-title">${n.notice_title}</td>
                  <td><fmt:formatDate value="${n.notice_date}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                  <td><a href="<%=request.getContextPath()%>/back/updateNotice?notice_id=${n.notice_id}">修改</a> <a rel="${n.notice_id}">删除</a></td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
          <h1 class="page-header">每日一句</h1>
          <textarea id="oText" maxlength='50' style="border:5px dotted pink;color:lightslategrey;width: 100%;height: 100px" οnfοcus="borderColor(this);" οnblur="clearTimeout(oTime);">${words.words_content}</textarea>
          <button id="addDayWords" type="button" class="btn btn-info">提交</button>
        </div>
      </form>
    </div>
    </div>
  </div>
</section>
<script src="js/bootstrap.min.js"></script>
<script src="js/admin-scripts.js"></script>

<Script Language="JavaScript">
  function borderColor(){
    if(self['oText'].style.borderColor=='pink'){
      self['oText'].style.borderColor = 'yellow';
    }else{
      self['oText'].style.borderColor = 'pink';
    }
    oTime = setTimeout('borderColor()',400);
  }
</Script>


<script>
//是否确认删除
$(function(){   
	$("#main table tbody tr td a").click(function(){
		var name = $(this);
		var id = name.attr("rel"); //对应id
		if (event.srcElement.outerText == "删除")
		{
			if(window.confirm("此操作不可逆，是否确认？"))
			{
              $.ajax({
                url : '<%=request.getContextPath()%>/back/notice/delete',
                type : 'get',
                dataType : 'json',
                data : {
                  "notice_id":id
                },
                success : function (data) {
                    window.location.href='<%=request.getContextPath()%>'+data.url;
                },
                error : function (data) {
                    window.location.href='<%=request.getContextPath()%>'+data.url;
                }
              })

			};
		};
	});   
});
</script>

<%--每日一练--%>
<script>
  $("#addDayWords").click(function () {
    var text = $("#oText").val();
    $.ajax({
      url : '<%=request.getContextPath()%>/back/notice/words/add',
      type : 'get',
      dataType : 'json',
      data : {
        "words_content":text
      },
      success : function (data) {
        alert(data.message);
      },
      error : function (data) {
        alert(data.message);
      }
    })

  })
</script>
</body>
</html>
